home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 46
/
Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso
/
-in_the_mag-
/
reader_requests
/
scilab
/
demos
/
tracking
/
track.dem
Wrap
Text File
|
1999-09-16
|
1KB
|
58 lines
//rand('seed',0)
rand('normal')
nx=5;
ny=1;
nu=3;
Plant=ssrand(ny,nu,nx);
J=rand(Plant(5));Plant(5)=0*J;
[F,G,H,J]=Plant(2:5);
nw=4;
nuu=2;
A=rand(nw,nw);
st=maxi(real(spec(A)));A=A-st*eye(A);
B=rand(nw,nuu);
C=2*rand(ny,nw);
D=0*rand(C*B);
xx0=0*ones(nw,1);
Model=syslin('c',A,B,C,D,xx0);
// Input to Model (t is a vector), nuu components
deff('[ut]=uu(t)','ut=[sin(3*t);cos(0.5*t)]');comp(uu);
// Signal to track
dt=0.05;tmax=60;
instants=0:dt:tmax;
totrack=flts(uu(instants),dscr(Model,dt)); //Signal
xbasc();
//plot2d(instants',totrack');
[L,M,T]=gfrancis(Plant,Model);
// Stabilizing the plant
K=-ppol(F,G,-0.3*ones(1,nx));
//[K,L,M,err]=deskre(Plant,Model,-0.3,-0.5,100);T=0*T;
// Bigsyst= closed loop system: um --> [yplant;ymodel].
// full state gain is [K, L - K*T] * (xplant, xmodel) + M * umodel
BigA=[F+G*K,G*(L-K*T);
0*ones(nw,nx),A];
BigC=[H+J*K,J*(L-K*T);
0*ones(ny,nx),C];
BigB=[G*M;
B];
BigD=[J*M;
D];
x0=ones(nx,1);
BigX0=[x0;xx0];
Bigsyst=dscr(syslin('c',BigA,BigB,BigC,BigD,BigX0),dt);
z=flts(uu(instants),Bigsyst);
//plot2d(instants',z(1,:)',-1,'000');
xbasc(0);xset("window",0);
plot2d([instants',instants'],[totrack(1,:)',z(1,:)']);xtitle('tracking');
//xbasc(1);driver("Rec");xset("window",1);//xselect();
//plot2d(totrack(1,:)',z(1,:)');
clear uu z bigsyst bigx0 x0 gfrancis bigd bigb bigc biga k l
clear instants tmax dt model plant a nuu nw f g h j
clear totrack m t d c b st nx nu ny xx0